<!DOCTYPE html>
<html th:replace="~{fragments/main :: layout(~{::title}, ~{::section}, ~{::popwin})}" xmlns:th="http://www.thymeleaf.org">
<head>
    <title>客服管理</title>
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
</head>
<body>
<section>
    <div class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label">编号：</label>
            <div class="layui-input-block">
                <label class="layui-form-label" style="text-align: left; width: 100%;">[[${account.id}]]</label>
                <input type="hidden" name="id" lay-filter="user" th:value="${account.id}"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">头像：</label>
            <div class="layui-input-block">
                <img th:src="${account.avatar}" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">微信用户名：</label>
            <div class="layui-input-block">
                <label class="layui-form-label" style="text-align: left; width: 100%;">[[${account.wxId}]]</label>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">别名：</label>
            <div class="layui-input-block">
                <label class="layui-form-label" style="text-align: left; width: 100%;">[[${account.alias}]]</label>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">昵称：</label>
            <div class="layui-input-block">
                <label class="layui-form-label" style="text-align: left; width: 100%;">[[${account.nick}]]</label>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">客服：</label>
            <div class="layui-input-block">
                <select name="csId" style="width: 300">
                    <option th:each="u : ${users}" th:value="${u.id}" th:selected="${u.id == account.csId}" th:text="${u.userName}"></option>
                </select>
            </div>
        </div>
        <div class="layui-form-item" >
            <label class="layui-form-label">最近活跃时间：</label>
            <div class="layui-input-block">
                <label class="layui-form-label" style="text-align: left; width: 100%;">[[${account.loginTime}]]</label>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">保存</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                <a href="/kf/manage" class="layui-btn layui-btn-primary">返回</a>
            </div>
        </div>
    </div>
    <script src="/layui/layui.js"></script>
    <script th:inline="javascript">
        layui.use(['form','table','layer'], function(){
            var form = layui.form;
            var $ = layui.jquery;
            form.render({});
            form.on('submit(formDemo)', function(data){
                $.ajax({
                    url:'/wx/save',
                    type:'post',
                    data:JSON.stringify(data.field),
                    contentType: "application/json;charset=utf-8",
                    dataType:'json',
                    success:function(data){
                        if(data.code == 500){
                            layer.msg(data.msg,{icon: 5});//失败的表情
                            return;
                        }else{
                            layer.msg(data.msg, {
                                icon: 6,//成功的表情
                                time: 1000 //1秒关闭（如果不配置，默认是3秒）
                            }, function(){
                            });
                        }
                    },
                    complete: function () {
                        layer.close(this.layerIndex);
                        window.location="/wx/manage";
                    }
                });
                return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
            });
        });
    </script>
</section>
<div th:fragment="popwin"></div>
</body>
</html>